//
//  def_unary_expression.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_unary_expression_h
#define compilation_def_unary_expression_h

/*
 
 unary_expression
 : postfix_expression {printf("unary_expression postfixe_expression\n");}
 | INC_OP unary_expression {printf("unary_expression INC OP unarty expression\n");}
 | DEC_OP unary_expression {printf("unary_expression DEC OP unary expression\n");}
 | unary_operator unary_expression {printf("unary_expression unary expression unexary expression\n");}
 ;
 */

struct def_unary_expression{
	void * parent;
	int type;
	struct def_postfixe_expression * postfix_expression;
	struct def_unary_expression * unary_expression;
	enum op unary_operator;
};

struct def_unary_expression * unary_expression_create(void * parent){
	struct def_unary_expression * f = malloc(sizeof(*f));
	f->parent = parent;
	f->type = 0;
	return f;
}

void unary_expression_print(struct def_unary_expression * f){
	switch(f->type){
		case 1:
			postfix_expression_print(f->postfix_expression);
			break;
		case 2:
			printf("++");
			unary_expression_print(f->unary_expression);
			break;
		case 3:
			printf("--");
			unary_expression_print(f->unary_expression);
			break;
		case 4:
			operator_print(f->unary_operator);
			unary_expression_print(f->unary_expression);
			break;
	}
}
#endif
